//
//  LLBannerCollectionViewCell.m
//  lrlzapp
//
//  Created by dl on 16/2/26.
//  Copyright © 2016年 lrlz. All rights reserved.
//

#import "LLBannerCollectionViewCell.h"
#import "LLbannerViewModel.h"
#import "LLBannerView.h"

@interface LLBannerCollectionViewCell ()
@property(nonatomic, strong) LLBannerViewModel *viewModel;
@property(nonatomic, strong) LLBannerView *bannerView;
@end

@implementation LLBannerCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.bannerView = [LLBannerView new];
        self.bannerView.options = LLBannerViewAutoScroll | LLBannerViewPageControllMidCenter;
        [self addSubview:self.bannerView];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.bannerView.frame = self.bounds;
}

- (void)bindViewModel:(id)viewModel {
    self.viewModel = viewModel;
    RAC(self.bannerView, imgUrls) = [RACObserve(self.viewModel, imgs)
            takeUntil:self.rac_prepareForReuseSignal];
    RAC(self.viewModel, curIndex) = [RACObserve(self.bannerView, curIndex)
            takeUntil:self.rac_prepareForReuseSignal];
}

- (void)stopTimer {
    [self.bannerView stopTimer];
}

- (void)startTimer {
    [self.bannerView startTimer];
}

@end
